﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            SortedList sortedlist = new SortedList();
            sortedlist.Add(1, "小明");
            sortedlist.Add(2, "小王");
            sortedlist.Add(3, "小胡");
            Console.WriteLine("请输入编号");
            int id = int.Parse(Console.ReadLine());
            bool flag = sortedlist.ContainsKey(id);
            if (flag)
            {
                String name = sortedlist[id].ToString();
                Console.WriteLine("您查找的人姓名为：{0}", name);
            }
            else { Console.WriteLine("您所查的编号不存在"); }
            Console.WriteLine("所有的编号如下");
            foreach (DictionaryEntry a in sortedlist) {
                int key = (int)a.Key;
                string value = a.Value.ToString();
                Console.WriteLine("编号：{0} 姓名：{1}",key ,value);
            }
        }       
    }
}
